#ifndef SQLEXPRESSION_H_INCLUDED
#define SQLEXPRESSION_H_INCLUDED

#include <string.h>
#include <vector>
#include <boost/regex.hpp>
#include<algorithm>
#include<iostream>
#include"ServerDB.h"
#include"ServerSocket.h"
using namespace std;
using namespace boost;

class SqlEx {
public:
	SqlEx(string ex);
	~SqlEx();
	bool check(CServerSocket*,ServerDB *, Authority *);
private:
	void Error();
	vector <string>simpleParse(string str);
	void where(string,vector<struct_where>&);

	bool ForCreateUser();
	bool ForGrant();
	bool ForDropUser();
	bool ForSetPwd();
	bool ForShowUser();

	bool ForUpdate();
	bool ForDelete();
	bool ForInsert();
	bool ForSelect();

	bool ForCreate();
	bool ForDrop();
	bool ForAddField();
	bool ForDropField();
	bool ForModifyField();
	bool ForShow();
	bool ForIndexCreate();

	bool ForUseDB();
	bool ForCreateDB();
	bool ForShowDB();
	bool ForDropDB();
	bool ForDesc();
	string sql(string str);
	
	string Ex;
	CServerSocket* pSocket;
	ServerDB *serverDB;
	Authority *authority;
	string user_host;
};


#endif // SQLEXPRESSION_H_INCLUDED